#ifndef PAGE4_H
#define PAGE4_H

#include <QWidget>
#include<QSqlTableModel>
#include"src/mes.h"
#include<QMenu>

namespace Ui {
class Page4;
}

class Page4 : public QWidget
{
    Q_OBJECT

public:
    explicit Page4(QWidget *parent = nullptr);
    ~Page4();

private slots:
    void on_pushButton_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_2_clicked();

    void slotContextMenu(QPoint pos);

    void slot_copyData();

private:
    Ui::Page4 *ui;
    void clearWidget();
    void initTableView();
    QStringList sqlist{"200"};
    QMenu *popMenu;

    int selectCurrentRow;
    int selectCurrentColumn;
};

class RepairTableModel:public QSqlTableModel
{
    Q_OBJECT
public:
    RepairTableModel( QObject * parent = 0, QSqlDatabase db = Mes::getInstance()->db );

    bool setData( const QModelIndex &index, const QVariant &value, int role) override;
    QVariant data(const QModelIndex &index, int role) const override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;

    void setSqlist(QStringList sqlist){this->sqlist=sqlist;};

    QMap<int, Qt::CheckState> check_state_map;

private:
    int checkColumn = 0;
    QStringList sqlist;

protected:
    QString selectStatement() const override;

};

#endif // PAGE4_H
